#include <xen/sched_ctl.h>
#include <xen/acm.h>
+#ifdef __ia64__
+#define XC_PAGE_SHIFT 14
+#else
+#define XC_PAGE_SHIFT 12
+#endif
+#define XC_PAGE_SIZE (1UL << XC_PAGE_SHIFT)
+#define XC_PAGE_MASK (~(XC_PAGE_SIZE-1))
+
/*
* DEFINITIONS FOR CPU BARRIERS
*/
#define mb() __asm__ __volatile__ ( "mfence" : : : "memory")
#define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
#define wmb() __asm__ __volatile__ ( "" : : : "memory")
+#elif defined(__ia64__)
+/* FIXME */
+#define mb()
+#define rmb()
+#define wmb()
#else
#error "Define barriers"
#endif
int xc_get_pfn_list(int xc_handle, u32 domid, unsigned long *pfn_buf,
unsigned long max_pfns);
+int xc_ia64_get_pfn_list(int xc_handle, u32 domid, unsigned long *pfn_buf,
+ unsigned int start_page, unsigned int nr_pages);
+
/*\
* GRANT TABLE FUNCTIONS
\*/
#define ELFSIZE 32
#endif
-#if defined(__x86_64__)
+#if defined(__x86_64__) || defined(__ia64__)
#define ELFSIZE 64
#endif
#define round_pgup(_p) (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
#define round_pgdown(_p) ((_p)&PAGE_MASK)
+#ifdef __ia64__
+#define probe_aout9(image,image_size,load_funcs) 1
+#endif
+
static int probeimageformat(char *image,
unsigned long image_size,
struct load_funcs *load_funcs)
}
#endif
+#ifdef __ia64__
+#include <asm/fpu.h> /* for FPSR_DEFAULT */
+static int setup_guest(int xc_handle,
+ u32 dom,
+ char *image, unsigned long image_size,
+ gzFile initrd_gfd, unsigned long initrd_len,
+ unsigned long nr_pages,
+ unsigned long *pvsi, unsigned long *pvke,
+ unsigned long *pvss, vcpu_guest_context_t *ctxt,
+ const char *cmdline,
+ unsigned long shared_info_frame,
+ unsigned int control_evtchn,
+ unsigned long flags,
+ unsigned int vcpus,
+ unsigned int store_evtchn, unsigned long *store_mfn)
+{
+ unsigned long *page_array = NULL;
+ struct load_funcs load_funcs;
+ struct domain_setup_info dsi;
+ unsigned long start_page;
+ int rc;
+
+ rc = probeimageformat(image, image_size, &load_funcs);
+ if ( rc != 0 )
+ goto error_out;
+
+ memset(&dsi, 0, sizeof(struct domain_setup_info));
+
+ rc = (load_funcs.parseimage)(image, image_size, &dsi);
+ if ( rc != 0 )
+ goto error_out;
+
+ dsi.v_start = round_pgdown(dsi.v_start);
+ dsi.v_end = round_pgup(dsi.v_end);
+
+ start_page = dsi.v_start >> PAGE_SHIFT;
+ nr_pages = (dsi.v_end - dsi.v_start) >> PAGE_SHIFT;
+ if ( (page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL )
+ {
+ PERROR("Could not allocate memory");
+ goto error_out;
+ }
+
+ if ( xc_ia64_get_pfn_list(xc_handle, dom, page_array, start_page, nr_pages) != nr_pages )
+ {
+ PERROR("Could not get the page frame list");
+ goto error_out;
+ }
+
+ (load_funcs.loadimage)(image, image_size, xc_handle, dom, page_array,
+ &dsi);
+
+ *pvke = dsi.v_kernentry;
+ return 0;
+
+ error_out:
+ if ( page_array != NULL )
+ free(page_array);
+ return -1;
+}
+#else /* x86 */
static int setup_guest(int xc_handle,
u32 dom,
char *image, unsigned long image_size,
free(page_array);
return -1;
}
+#endif
int xc_linux_build(int xc_handle,
u32 domid,
}
if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
+#ifdef __ia64__
+ 0 )
+#else
(ctxt->ctrlreg[3] != 0) )
+#endif
{
ERROR("Domain is already constructed");
goto error_out;
if ( image != NULL )
free(image);
+#ifdef __ia64__
+ /* based on new_thread in xen/arch/ia64/domain.c */
+ ctxt->regs.cr_ipsr = 0; /* all necessary bits filled by hypervisor */
+ ctxt->regs.cr_iip = vkern_entry;
+ ctxt->regs.cr_ifs = 1UL << 63;
+ ctxt->regs.ar_fpsr = FPSR_DEFAULT;
+ /* ctxt->regs.r28 = dom_fw_setup(); currently done by hypervisor, should move here */
+ ctxt->vcpu.privregs = 0;
+ ctxt->shared.domain_controller_evtchn = control_evtchn;
+ ctxt->shared.flags = flags;
+ i = 0; /* silence unused variable warning */
+#else /* x86 */
/*
* Initial register values:
* DS,ES,FS,GS = FLAT_KERNEL_DS
ctxt->failsafe_callback_eip = 0;
ctxt->syscall_callback_eip = 0;
#endif
+#endif /* x86 */
memset( &launch_op, 0, sizeof(launch_op) );
return (ret < 0) ? -1 : op.u.getmemlist.num_pfns;
}
+#ifdef __ia64__
+int xc_ia64_get_pfn_list(int xc_handle,
+ u32 domid,
+ unsigned long *pfn_buf,
+ unsigned int start_page,
+ unsigned int nr_pages)
+{
+ dom0_op_t op;
+ int ret;
+
+ op.cmd = DOM0_GETMEMLIST;
+ op.u.getmemlist.domain = (domid_t)domid;
+ op.u.getmemlist.max_pfns = ((unsigned long)start_page << 32) | nr_pages;
+ op.u.getmemlist.buffer = pfn_buf;
+
+ if ( mlock(pfn_buf, nr_pages * sizeof(unsigned long)) != 0 )
+ {
+ PERROR("Could not lock pfn list buffer");
+ return -1;
+ }
+
+ /* XXX Hack to put pages in TLB, hypervisor should be able to handle this */
+ memset(pfn_buf, 0, nr_pages * sizeof(unsigned long));
+ ret = do_dom0_op(xc_handle, &op);
+
+ (void)munlock(pfn_buf, nr_pages * sizeof(unsigned long));
+
+ return (ret < 0) ? -1 : op.u.getmemlist.num_pfns;
+}
+#endif
+
long xc_get_tot_pages(int xc_handle, u32 domid)
{
dom0_op_t op;